🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / model / src / commonMain / kotlin / org / meshtastic / core / model / Mention.kt
Displaying Raw • Download
core/model/src/commonMain/kotlin/org/meshtastic/core/model/Mention.kt bd2863243bab6eb213401d949839a2bc74dde7e2 (bd286324) Text, 1.72 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.model
T8b949e/**
* The @mention wire token: `@` followed by a node's hex user id (`@!ffccee11`). This is the single source of truth for
* the cross-platform wire format (see meshtastic/design#21) so the compose input, message rendering, and notification
* paths all detect it identically. The 8-hex run plus the negative lookahead reject a partial match against a longer
* id.
*/
Tff7b72val Te6edf3MENTION_TOKEN_REGEX Tff7b72= Te6edf3RegexTb4b4b4(Ta5d6ff"""Ta5d6ff@(![0-9a-fA-F]{8})(?![0-9a-fA-F])Ta5d6ff"""Tb4b4b4)
T8b949e/**
* True if [text] @mentions the node whose hex user id is [userId] (e.g. `!ffccee11`), honoring the token boundary — a
* trailing hex digit (`@!ffccee11a`) is a different, longer id and is not a match.
*/
Tff7b72fun Td2a8fftextMentionsNodeTb4b4b4(Te6edf3textTb4b4b4: Tffa657String?Tb4b4b4, Te6edf3userIdTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3textTb4b4b4.Te6edf3isNullOrEmptyTb4b4b4(Tb4b4b4) Tff7b72|Tff7b72| Te6edf3userIdTb4b4b4.Te6edf3length Tff7b72<Tff7b72= T79c0ff1Tb4b4b4) Tff7b72return Tff7b72false
T8b949e// Derive from the shared token regex so the format/boundary rule lives in exactly one place.
Tff7b72return Te6edf3MENTION_TOKEN_REGEXTb4b4b4.Te6edf3findAllTb4b4b4(Te6edf3textTb4b4b4)Tb4b4b4.Te6edf3any Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3groupValuesTff7b72[T79c0ff1Tff7b72]Tb4b4b4.Te6edf3equalsTb4b4b4(Te6edf3userIdTb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4) Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s